from django.db import models
from django.contrib.auth.models import User


class Course(models.Model):
    user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='course_user')
    title = models.CharField(max_length=30)
    overview = models.TextField()
    created = models.DateTimeField(auto_now_add=True)

    class Meta:
        """
         内部类设置排序字段，以创建时间的倒序排序
        """
        ordering = ('-created',)

    def __str__(self):
        return self.title